package com.jisf.driver.entity.enumtype;

import com.alibaba.fastjson.annotation.JSONType;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.ToString;

import java.util.Arrays;
import java.util.Objects;

/**
 * @Classname CoursePeriodEnum
 * @Description TODO 课程时间段
 * @Date 2022/4/23 14:52
 * @Created by jisf：【429627912@qq.com】
 */
//@JSONType(serializeEnumAsJavaBean = true)
public enum CoursePeriodEnum implements BaseEnum<CoursePeriodEnum, Integer>{

    ONE_PERIOD(1, "8:00 - 9:00"),
    TWO_PERIOD(2, "9:00 - 10:00"),
    THREE_PERIOD(3, "10:00 - 11:00"),
    FOUR_PERIOD(4, "11:00 - 12:00"),
    FIVE_PERIOD(5, "14:00 - 15:00"),
    SIX_PERIOD(6, "15:00 - 16:00"),
    SEVEN_PERIOD(7, "16:00 - 17:00"),
    EIGHT_PERIOD(8, "17:00 - 18:00"),
    ;

//    @EnumValue
    private Integer code;

    @JsonValue
    private String name;

    CoursePeriodEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static CoursePeriodEnum getEnum(Integer code) {
        for (CoursePeriodEnum e : CoursePeriodEnum.values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        return null;
    }

    public static CoursePeriodEnum getEnum(String name){
        for (CoursePeriodEnum e : CoursePeriodEnum.values()) {
            if (e.getName().equals(name)) {
                return e;
            }
        }
        return null;
    }
}
